<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/application.css" />">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/listdata.css"></c:url>">
	<% int a = 0;%>
	
	<script type="text/javascript" src="<c:url value="/js/common.js"/>"></script>
	<script type="text/javascript">
	
	     function orderProcess(id,status){
              if(confirm("请确认您的订单操作!")){
               location.href="<c:url value="/myDD?act=orderProcess&orderId="/>"+id+"&orderStatus="+status;
            }
          
         }
	
	      function custComment(bookCode,orderId){
	      location.href="<c:url value="/comment?act=toComment&bookCode="/>"+bookCode+"&orderId="+orderId;
	      }
	
	      function doQuery(pageno)
          {
            if(pageno<1 || pageno>${page.totalPageNum})
            {
              alert("页号超出范围，有效范围：[1-${page.totalPageNum}]!");
              ${'pageNo'}.select();
              return;
            }
            
             location.href="<c:url value="/myDD?act=CustOrder&pageno="/>"+pageno;
            
         }
	
	</script>

  </head>
  
  <body>
     <div class="listTitle"> 
      >> 我的订单列表
     </div>
     
    <c:if test="${not empty page.pageContent}">
    <c:forEach items="${page.pageContent}" var="order">
    <table class="listable" cellspacing=0 cellpadding=0 border=0>
         <tr>
              <td>
	            <div align="left"><strong>订单号</strong>：${order.orderId}
	            <strong  style="margin-left:35px;">时间</strong>：<fmt:formatDate value="${order.orderTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
	            <strong style="margin-left:35px;">买家</strong>：${order.customer.customerName}
	            <strong style="margin-left:35px;">订单状态</strong>：<c:if test="${order.orderStatus=='A'}">提交订单</c:if>
	                                                              <c:if test="${order.orderStatus=='B'}">审核,未发货</c:if>
	                                                              <c:if test="${order.orderStatus=='C'}">已发货</c:if>
	                                                              <c:if test="${order.orderStatus=='D'}">完成订单</c:if>
	                                                              <c:if test="${order.orderStatus=='E'}">订单已取消</c:if>
	                                                              <c:if test="${order.orderStatus=='F'}">已收货</c:if>
	            </div>
	            <c:if test="${order.orderStatus=='C'}">
	            <span title="订单[${order.orderId}]发货" class="linkSpan" onclick="orderProcess('${order.orderId}','F')">已收货</span>
	             </c:if>
	            
	             
	             </td>
        </tr>
        <c:forEach items="${orderItems}" var="orderItem">
        <c:if test="${orderItem.orderId==order.orderId}">
          <tr>
          <td><div align="left">
	            <img onclick="location.href='<c:url value="/bookMgr?act=showcover&bookcode=${orderItem.book.bookCode}"/>';"
                       title="点图片查看大图"
                       style="width:50px; height:50px;" 
                       src="<c:url value="/bookMgr?act=showcover&bookcode=${orderItem.book.bookCode}"/>">
                  </img>
                  <tt style="margin-left:40px; width: 200px;">${orderItem.book.bookName}</tt>
                  <tt style="margin-left:40px; width: 100px;">${orderItem.book.bookAuthor}</tt>
                  <tt style="margin-left:80px;">￥${orderItem.book.bookPrice}</tt>
                  <tt style="margin-left:80px;">${orderItem.itemBookAmount}</tt>
                  <tt style="margin-left:80px;">
                  
                  
                  <c:if test="${order.orderStatus=='D'}">
                  <c:forEach items="${comments.pageContent}" var="comment">
                  <c:if test="${comment.orderInfo.orderId==order.orderId&&comment.book.bookCode==orderItem.book.bookCode}">
                  <%a=10; %>
	             </c:if>
	             </c:forEach>
	            <% if(a!=10){%><span title="订单[${order.orderId}评价]" class="linkSpan" onclick="custComment('${orderItem.book.bookCode}','${order.orderId}')">评价</span><%} %>
	             <%a=0; %>
	             </c:if>
	             </tt>
                  </div>
             </td>     
        </tr>
        </c:if>
       </c:forEach>
              <tr bgcolor="#F3F3F3">
               <td>
	            <div align="left"><strong>支付方式</strong>：${order.payMode}
                <strong style="margin-left:35px;">送货方式</strong>：${order.deliveryMode}
	            <strong style="margin-left:35px;">收货地址</strong>：${order.receiveAddr.receiverAddr}
                <strong style="margin-left:35px;">订单金额</strong>：${order.orderAmount}</div>
                
               </tr>
    
    </table>
    <hr>
    </c:forEach>
       <div id="pageinfo" style="float:right; margin:5px; padding-right:3px;">
		            共${page.totalRecNum}条, 当前显示${page.startIndex+1}-${page.endIndex}条, 第${page.pageNo}/${page.totalPageNum}页
		           |
		           <c:if test="${page.pageNo>1}">
		             <span class="linkspan" onclick="doQuery(1)">首页</span>&nbsp;
		           </c:if>
		           <c:if test="${page.prePage}">
		             <span class="linkspan" onclick="doQuery(${page.pageNo-1})">上一页</span>&nbsp;
		           </c:if>
		           <c:if test="${page.nextPage}">
		             <span class="linkspan" onclick="doQuery(${page.pageNo+1})">下一页</span>&nbsp;
		           </c:if>
		           <c:if test="${page.pageNo!=page.totalPageNum}">
		             <span class="linkspan" onclick="doQuery(${page.totalPageNum})">末页</span>&nbsp;
		           </c:if>
		           |
		            到<input type="text" id="pageNo" size=4 style="text-align:right;" onkeypress="onlynumber();"/> 页
		           <button onclick="doQuery($('pageNo').value);"> 跳 转 </button>		           		           	           	              
		        </div>
	     </div>
    </c:if>
	<c:if test="${empty page.pageContent}">
           <center>
	        <div id="noRecord" style="margin-top:80px;width:30%;height:70px;border:1px solid #c1cdd8;text-align:center;">
	          <span style="margin-top:20px;color:red;">没有符合条件的订单信息被找到!</span>
	          <br/>
	          <br/>
	          <button onclick="history.go(-1);"> 返 回 </button>
	        </div>
	       </center>	  
    </c:if>     
  </body>
</html>
